import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
import './style.css'

const app = createApp(App)

// 性能优化：抑制不必要的警告
app.config.warnHandler = (msg, instance, trace) => {
  // 只在开发环境显示严重警告
  if (import.meta.env.DEV && !msg.includes('extraneous non-props')) {
    console.warn(msg)
  }
}

// 性能优化：错误处理
app.config.errorHandler = (err, instance, info) => {
  console.error('应用错误:', err, info)
}

// 性能优化：只注册常用图标（减少注册时间）
const commonIcons = [
  'Refresh', 'Aim', 'Location', 'PriceTag', 'List', 'Camera',
  'Close', 'Check', 'Warning', 'InfoFilled', 'Delete', 'Edit',
  'Plus', 'Minus', 'Search', 'Download', 'Upload'
]

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  if (commonIcons.includes(key)) {
    app.component(key, component)
  }
}

// 注册 Element Plus
app.use(ElementPlus, {
  // 性能优化配置
  size: 'default',
  zIndex: 2000
})

app.mount('#app')

